﻿

using UnityEngine;

namespace Gameplay.CharacterFramework
{
    public abstract class Skill : ScriptableObject
    {
        public SkillConfig Config;
        public Weapon CurrentWeapon { get; set; }

        protected Role _user;
        protected Role _target;
        protected AnimationComponent _animationComponent;
        protected PhysicsComponent _physicsComponent;
        protected ParticleManager _particleManager;
        protected WeaponManager _weaponManager;

        public virtual void Init(Role user) 
        {
            _user = user;
            _animationComponent = user.AnimationComponent;
            _physicsComponent = user.PhysicsComponent;
            _particleManager = user.ParticleManager;
            _weaponManager= user.WeaponManager;
        }

        public virtual void Use(Role user)
        {
            Init(user);
            _user.Status.IsUsing = true;
            if (Config.Clip != null) 
            {
                _user.AnimationComponent.PlayCustomSkill(Config.Clip);
            }
        }

        public virtual void Use(Role user,Role target)
        {
            Init(user);
            _target =target;
            _user.Status.IsUsing = true;
            if (Config.Clip != null)
            {
                _user.AnimationComponent.PlayCustomSkill(Config.Clip);
            }

        }
        public virtual void Begin()
        {
           
        }
        public virtual void Trigger()
        {
         
            if (Config.effectSound != null)
            {
                AudioManager.Instance.PlaySound(Config.effectSound);
            }
        }
        public virtual void Finish() 
        {
          
        }
        public virtual void End()
        {
         
            _user.Status.IsUsing = false;
        }
        public virtual void Update() { }
        public virtual void Canel(){}
    }
}
